<template>
    <el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-position="left" label-width="80px">
      <el-form-item label="用户名" prop="username">
        <el-input v-model="loginForm.username" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="loginForm.password" type="password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">登录</el-button>
      </el-form-item>
    </el-form>
  </template>
  <script>
  export default {
    data() {
      return {
        loginForm: {
          username: '',
          password: ''
        },

        loginRules: {
          username: [
            { required: true, message: '请输入用户名', trigger: 'blur' }
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' }
          ]
        }
      }
    },

    methods: {
      submitForm() {
        this.$refs.loginForm.validate(valid => {
          if (valid) {
            // 表单验证通过，可以提交表单数据
            // TODO: 处理表单提交逻辑
          } else {
            // 表单验证失败，提醒用户输入正确的数据
            return false
          }
        })
      }
    }
  }
</script>
<style>
</style>